#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include<SDL/SDL_ttf.h>

/* Inclusion du header de SDL_image (adapter le dossier au besoin)
execution : gcc main.c -lSDL -lSDL_image -lSDL_mixer -o game*/

void pause();

int main(int argc, char *argv[])
{

char t[30];



int continuer = 1, i;
SDL_Event event;

    SDL_Surface *ecran = NULL, *imageDeFond = NULL, *perso[2] ,  *bal = NULL,*texte;
    SDL_Rect positionFond;
 	SDL_Rect po1;
	SDL_Rect positionbal , positionscore;
 	SDL_Init(SDL_INIT_VIDEO);
    positionFond.x = 0;
    positionFond.y = 0;
	positionbal.x = 600;
	positionbal.y = 200;
    po1.x = 600;
    po1.y = 300;
positionscore.x=300;
positionscore.y=100;

   	 ecran = SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE);
   	 SDL_WM_SetCaption("Street basket", NULL);

   	 imageDeFond = IMG_Load("bg.jpg");
  	bal=IMG_Load("balle1.png");

    /* Chargement d'un PNG avec IMG_Load
    Celui-ci est automatiquement rendu transparent car les informations de
    transparence sont codées à l'intérieur du fichier PNG */

perso[0] = IMG_Load("b4.png");

perso[1] = IMG_Load("b1.png");



 SDL_Flip(ecran);
    while (continuer)
    {

        SDL_WaitEvent(&event);
        switch(event.type)
        {
            case SDL_QUIT:

                continuer = 0;
        }

      if(event.type==SDL_KEYDOWN)
{

if(event.key.keysym.sym==SDLK_ESCAPE)
{
      SDL_Quit();
   break;
}

        if(event.key.keysym.sym==SDLK_RIGHT)

{
sprintf(t, "Score ");
SDL_BlitSurface(imageDeFond, NULL, ecran, &positionFond);
SDL_BlitSurface(perso[1], NULL, ecran, &po1);
SDL_BlitSurface(bal,NULL,ecran,&positionbal);
SDL_BlitSurface(texte, NULL, ecran, &positionscore);
    SDL_Flip(ecran);
}

}

for(i=0 ;i <1  ;i++)
{
sprintf(t, "Score ");

 SDL_BlitSurface(imageDeFond, NULL, ecran, &positionFond);

SDL_BlitSurface(perso[i], NULL, ecran, &po1);
SDL_BlitSurface(bal, NULL, ecran, &positionbal);
SDL_BlitSurface(texte, NULL, ecran, &positionscore);


SDL_Delay(70);

    SDL_Flip(ecran);
}

}

    SDL_FreeSurface(imageDeFond);
    SDL_FreeSurface(perso[i]);
	SDL_FreeSurface(bal);
    SDL_Quit();

    return EXIT_SUCCESS;
}

